package com.zheng.damo01.liko;

import java.util.ArrayList;

public class Solution {
    public static void main(String[] args) {
        int abcabcbb = new Solution().lengthOfLongestSubstring("asdfhjklfd");
        System.out.println(abcabcbb);
    }
    public int lengthOfLongestSubstring(String s) {
        if (s.equals("")){
            return 0;
        }
        char[] arr = s.toCharArray();
        ArrayList<Character> lits = new ArrayList<>();
        ArrayList<String> lits1 = new ArrayList<>();
        for (int i = 0; i < arr.length; i++) {
            for (int j = i; j < arr.length; j++) {
                if (!lits.contains(arr[j])) {
                    lits.add(arr[j]);
                } else {
                    String sum="";
                    for (Character lit : lits) {
                        sum=sum+lit;
                    }
                    lits1.add(sum);
                    lits.clear();
                    break;
                }
            }
        }
        int max=0;
        for (String s1 : lits1) {
            if (s1.length()>max){
                max=s1.length();
            }
        }
        return max;
    }

}
